home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / bc7eqget.zip / BC7EQGET.BAS < prev    next >
BASIC Source File  |  1990-03-27  |  7KB  |  204 lines

  1.  
  2.   ' BC7EqGet.Bas  03-26-90  Use Interrupt in MS Basic 7.x
  3.   ' ------------  Remember to invoke QBX fn /lQBX              <-- Note !
  4.   ' Author: T. E. McCormick
  5.   ' Liberal use of two functions in QB4INT.ZIP by author unknown:
  6.     DECLARE SUB IntToBin (Byte%, Bin$)
  7.   '             IntToBin()   ...creates binary bit display string
  8.     DECLARE SUB Breakword (dataword%, highbyte%, lowbyte%)
  9.   '             BreakWord()  ...breaks 16 bit reg into two 8 bit variables
  10.  
  11.   '$INCLUDE: 'QBX.BI'
  12.    DIM inregs AS RegType, outregs AS RegType
  13.  
  14.    DEFINT A-Z
  15.    False% = 0: True% = -1
  16.    CLS
  17.  
  18.  
  19.  '---------------------------------------------------------------------
  20.  '-----  EXAMPLES USING `INTERRUPT` WITH MS BASIC VER. 7.X        -----
  21.  '-----  NOTE:  Function hex values go in the HIGH Byte of AX     -----
  22.  '---------------------------------------------------------------------
  23.  
  24. Peripherals:
  25.   inregs.AX = &H1100
  26.   Interrupt &H11, inregs, outregs   ' 11: Peripheral Equip Installed
  27.     I.Word% = outregs.AX
  28.       CALL Breakword(I.Word%, High%, Low%)
  29.       I.Reg$ = "AX": GOSUB I.ShowRegReturn  ' Debugging
  30.  
  31.     CALL IntToBin(High%, High$)     ' Bit Strings
  32.     CALL IntToBin(Low%, Low$)
  33.  
  34.     W.Bits$ = LEFT$(High$, 2)       ' bits e and f are highest
  35.       IF W.Bits$ = "00" THEN I.ParPrinters% = 0   ' Parallel printer(s)
  36.       IF W.Bits$ = "01" THEN I.ParPrinters% = 1
  37.       IF W.Bits$ = "10" THEN I.ParPrinters% = 2
  38.       IF W.Bits$ = "11" THEN I.ParPrinters% = 3
  39.     IF MID$(High$, 4, 1) = "1" THEN
  40.      I.GamePorts% = 1
  41.     ELSE I.GamePorts% = 0
  42.     END IF
  43.  
  44.     W.Bits$ = MID$(High$, 5, 3)
  45.       IF W.Bits$ = "000" THEN I.SerialPorts% = 0
  46.       IF W.Bits$ = "001" THEN I.SerialPorts% = 1
  47.       IF W.Bits$ = "010" THEN I.SerialPorts% = 2
  48.       IF W.Bits$ = "011" THEN I.SerialPorts% = 3
  49.       IF W.Bits$ = "100" THEN I.SerialPorts% = 4
  50.  
  51.     W.Bits$ = LEFT$(Low$, 2)
  52.       IF RIGHT$(Low$, 1) = "0" THEN
  53.        I.DisketteDrives% = 0
  54.       ELSE
  55.        IF W.Bits$ = "00" THEN I.DisketteDrives% = 1
  56.        IF W.Bits$ = "01" THEN I.DisketteDrives% = 2
  57.        IF W.Bits$ = "10" THEN I.DisketteDrives% = 3
  58.        IF W.Bits$ = "11" THEN I.DisketteDrives% = 4
  59.       END IF
  60.  
  61.       IF MID$(Low$, 7, 1) = "1" THEN
  62.        I.CoProcessor% = 1
  63.       ELSE I.CoProcessor% = 0
  64.       END IF
  65.  
  66. GetDate:
  67.   inregs.AX = &H2A00                ' Get Date (& Day of Week 0-6 Sun-Sat)
  68.   Interrupt &H21, inregs, outregs   ' 21: DOS Services
  69.     I.DayOfWeek$ = "Sunday   Monday   Tuesday  Wednesday"
  70.     I.DayOfWeek$ = I.DayOfWeek$ + "Thurdsay Friday   Saturday "
  71.     I.Word% = outregs.AX
  72.       CALL Breakword(I.Word%, High%, Low%)
  73.       I.Reg$ = "AX": GOSUB I.ShowRegReturn  ' Debugging
  74.     Temp% = ((Low% + 1) * 9) - 8    ' 1st letter
  75.     I.WeekDay$ = MID$(I.DayOfWeek$, Temp%, 9)
  76.     I.WeekDay$ = RTRIM$(I.WeekDay$)
  77.     I.WeekdayAbbrev$ = LEFT$(I.WeekDay$, 3)
  78.     I.Year% = outregs.cx           ' Year range 1980 - 2099
  79.     I.Word% = outregs.DX           ' Month and Day
  80.       CALL Breakword(I.Word%, High%, Low%)
  81.       I.Reg$ = "DX": GOSUB I.ShowRegReturn  ' Debugging
  82.     I.Month% = High%
  83.     I.Day% = Low%
  84.  
  85. GetDosVersion:
  86.   inregs.AX = &H3000                ' Get Current DOS Major & Minor Ver.
  87.   Interrupt &H21, inregs, outregs   ' 21: DOS Services
  88.     I.Word% = outregs.AX
  89.       CALL Breakword(I.Word%, High%, Low%)
  90.       I.Reg$ = "AX": GOSUB I.ShowRegReturn  ' Debugging
  91.     I.DosMajor% = Low%
  92.     I.DosMinor% = High%
  93.     I.DosVer$ = LTRIM$(STR$(Low%)) + "." + LTRIM$(STR$(High%))
  94.  
  95. GetVideoMode:
  96.   inregs.AX = &HF00                 ' Get Current Video Mode
  97.   Interrupt &H10, inregs, outregs   ' 10: Video I/O ROM BIOS
  98.     I.Word% = outregs.AX
  99.       CALL Breakword(I.Word%, High%, Low%)
  100.       I.Reg$ = "AX": GOSUB I.ShowRegReturn  ' Debugging
  101.     I.Columns% = Low%
  102.     I.CurVideoMode% = High%
  103.   IF I.CurVideoMode% = 7 THEN
  104.        I.CrtColor% = False%
  105.   ELSE I.CrtColor% = True%
  106.   END IF
  107.  
  108. GetCursorPosition:
  109.   inregs.AX = &H300                 ' Get Current Cursor Row & Column
  110.   Interrupt &H10, inregs, outregs   ' 10: Video I/O ROM BIOS
  111.     I.Word% = outregs.DX
  112.       CALL Breakword(I.Word%, High%, Low%)
  113.       I.Reg$ = "DX": GOSUB I.ShowRegReturn  ' Debugging
  114.     I.CursorColumn% = Low% + 1      ' Returns 0-39, 0-79, etc.
  115.     I.CursorRow% = High% + 1        ' Returns 0-24, etc.
  116.  
  117. HighMemory:
  118.   inregs.AX = &H8800
  119.   Interrupt &H15, inregs, outregs   ' 15: Hi Mem 1k blocks above 640 k
  120.     I.MemHigh% = outregs.AX
  121.     I.Word% = outregs.AX
  122.       CALL Breakword(I.Word%, High%, Low%)
  123.       I.Reg$ = "AX": GOSUB I.ShowRegReturn  ' Debugging
  124.  
  125.   GOSUB I.ShowVariables
  126.   SYSTEM
  127.  
  128.  
  129.   '----------------------------------------------------------------------
  130.   'I.ShowRegReturn:     Subroutine to display high and low of any
  131.   '----------------     16 bit register returned after INTERRUPT.
  132.   'Place 16 bit register value in  I.Word% before GOSUB:
  133.   '      for example I.Word% = outregs.ax
  134.   'Place 2-character register ID in I.Reg$ before GOSUB:
  135.   '      for example I.Reg$ = "AX"
  136.   '----------------------------------------------------------------------
  137. I.ShowRegReturn:
  138.   PRINT STRING$(39, 196)   ' Divider bar for readability
  139.   CALL Breakword(I.Word%, High%, Low%)
  140.        PRINT I.Reg$; " Reg: "; I.Word%; TAB(16);
  141.        PRINT "  High="; High; "   Low="; Low
  142.   CALL IntToBin(High%, High$)
  143.   CALL IntToBin(Low%, Low$)
  144.        PRINT "                 fedcba98   76543210 "
  145.        PRINT I.Reg$; " bit string:   "; High$; "   "; Low$
  146.   RETURN
  147.  '------
  148.  
  149. I.ShowVariables:
  150.    PRINT "Press ENTER to see variables contents: ";
  151.    INPUT "", Dummy$
  152.    CLS
  153.    PRINT "Parallel Printer Port(s).......... : "; I.ParPrinters%
  154.    PRINT "Serial Port(s).................... : "; I.SerialPorts%
  155.    PRINT "Diskette drive(s)................. : "; I.DisketteDrives%
  156.    PRINT "Game Port? 0=No................... : "; I.GamePorts%
  157.    PRINT "80x87 Math Coprocessor? 0=No...... : "; I.CoProcessor%
  158.    PRINT "Day of Week, Month, Day, Year..... :  ";
  159.           PRINT I.WeekDay$; " "; I.Month%; " "; I.Day%; " "; I.Year%
  160.    PRINT "DOS Major and Minor versions...... :  "; I.DosVer$
  161.    PRINT "Color or Monochrome? 0=Mono....... : "; I.CrtColor%
  162.    PRINT "Memory above 640k (in k).......... : "; I.MemHigh%
  163.    RETURN
  164.   '------
  165.  
  166.  '_____________________________________________________________________
  167.  '
  168.  '     BreakWord() takes an integer argument and returns two integers
  169.  '     representing the high and low bytes of the original.
  170.  '_____________________________________________________________________
  171.  '
  172.    SUB Breakword (dataword, highbyte, lowbyte)
  173.  
  174.    IF dataword < 0 THEN
  175.     highbyte = (dataword + 2 ^ 16) \ 256 'check for high BIT set
  176.    ELSE highbyte = dataword \ 256            'integer divide off low byte
  177.    END IF
  178.  
  179.    lowbyte = dataword AND 255                'AND off the top byte
  180.  
  181.    END SUB
  182.  
  183.  '_____________________________________________________________________
  184.  '
  185.  '    IntToBin() takes an INTEGER argument and produces a
  186.  '    binary string representation of the INTEGER.
  187.  '_____________________________________________________________________
  188.  '
  189.    SUB IntToBin (Byte%, Bin$)
  190.    Bin$ = ""
  191.    Temp% = Byte%
  192.  
  193.      FOR I = 0 TO 7
  194.       IF Temp% AND 1 THEN
  195.            Bin$ = "1" + Bin$
  196.       ELSE
  197.            Bin$ = "0" + Bin$
  198.       END IF
  199.        Temp% = Temp% \ 2
  200.      NEXT
  201.  
  202.    END SUB
  203.  
  204.